import {post} from "./Request";

export async function add(url, params = {}) {
    return await post(`${url}/add`, params);
}

export async function update(url, params = {}) {
    return await post(`${url}/update`, params);
}

export async function remove(url, id) {
    return await post(`${url}/delete`, id);
}

export async function submit(url, params = {}) {
    return await post(`${url}`, params);
}

export async function page(url, params = {}) {
    const {current: pageNum, pageSize, ...data} = params;

    let {page, success} = await post(`${url}/page`, {
        pageNum, pageSize, data,
    });

    return {
        list: page?.list,
        total: page?.total,
        success,
    };

}

export async function list(url, params = {}) {
    const {list, success} = await post(`${url}/list`, params);
    return {list, success}
}


export async function query(url, params = {}) {
    const {data, success} = await post(url, params);
    return {data, success};
}


export async function get(url, id) {
    const {data, success} = await post(`${url}/one`, id);
    return {data, success};
}